// JavaScript Document
$(function() {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		var name = $( "#name" ),
			description = $( "#description" ),
			contact = $( "#contact" );
		
		$( "#create-dialog-form" ).dialog({
			autoOpen: false,
			height: 350,
			width: 500,
			modal: true,
			buttons: {
				"Create program": function() {
					$( "#programList tbody" ).append( "<tr>" +
						"<td><input type=\"radio\" name=\"program\"/> </td>" +
						"<td>" + name.val() + "</td>" + 
						"<td>" + description.val() + "</td>" + 
						"<td>" + contact.val() + "</td>" +
						"<td class=\"center\">Yes</td>" +
						"</tr>" ); 
					$( this ).dialog( "close" );
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});

		$( "#create-program" )
			.button()
			.click(function() {
				$( "#create-dialog-form" ).dialog( "open" );
			});
	});